home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / AppInstall / Cache.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  3.0 KB  |  82 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import warnings
  5. warnings.filterwarnings('ignore', 'apt API not stable yet', FutureWarning)
  6. import apt
  7. import os
  8.  
  9. class MyCache(apt.Cache):
  10.     
  11.     def __init__(self, progress = None):
  12.         apt.Cache.__init__(self, progress)
  13.         pipe = os.popen('dpkg --print-architecture')
  14.         self._arch = pipe.read().strip()
  15.         del pipe
  16.         if not self._depcache.BrokenCount == 0:
  17.             raise AssertionError
  18.  
  19.     
  20.     def pkgDependsOn(self, pkgname, depends_name):
  21.         ''' check if a given pkg depends on a given dependencie '''
  22.         if not self.has_key(pkgname):
  23.             return False
  24.         pkg = self[pkgname]
  25.         candver = self._depcache.GetCandidateVer(pkg._pkg)
  26.         if candver == None:
  27.             return False
  28.         dependslist = candver.DependsList
  29.         for dep in dependslist.keys():
  30.             if dep == 'Depends' and dep == 'PreDepends' or dep == 'Recommends':
  31.                 for depVerList in dependslist[dep]:
  32.                     for z in depVerList:
  33.                         for tpkg in z.AllTargets():
  34.                             if depends_name == tpkg.ParentPkg.Name:
  35.                                 return True
  36.                         
  37.                     
  38.                 
  39.             depends_name == tpkg.ParentPkg.Name
  40.         
  41.         return False
  42.  
  43.     
  44.     def clean(self):
  45.         self._depcache.Init()
  46.         if self._depcache.BrokenCount > 0:
  47.             print [](_[1])
  48.             self._depcache.Init()
  49.         
  50.         if self._depcache.DelCount > 0:
  51.             print [](_[2])
  52.             self._depcache.Init()
  53.         
  54.         if not self._depcache.DelCount == 0:
  55.             raise AssertionError
  56.  
  57.     
  58.     def getArch(self):
  59.         ''' Return the cpu architecture of the system'''
  60.         return self._arch
  61.  
  62.     
  63.     def getDependantAutoDeps(self, to_rm):
  64.         ''' return the installed automatic dependencies for the selected set
  65.             of packages that are going to be removed '''
  66.         auto_deps = set()
  67.         for pkg in to_rm:
  68.             self[pkg].markDelete()
  69.         
  70.         for pkg in self:
  71.             if not (pkg.markedDelete) and self._depcache.IsGarbage(pkg._pkg):
  72.                 for rm_package in to_rm:
  73.                     if self.pkgDependsOn(rm_package, pkg.name):
  74.                         print '%s is garbage and a dep of %s' % (pkg.name, rm_package)
  75.                         auto_deps.add(pkg.name)
  76.                         continue
  77.                 
  78.         
  79.         return auto_deps
  80.  
  81.  
  82.